From 88830744978e9f3fdeacc76028b59855743e47c6 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 10 Jul 2014 10:33:27 -0400 Subject: [PATCH] inspector: Disable non-functional controls Some of the features we expose can be hardcoded via environment variables. In that case, don't confuse the user by letting them change settings that have no effect. --- gtk/inspector/general.c | 11 +++++++++++ gtk/inspector/visual.c | 16 ++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/gtk/inspector/general.c b/gtk/inspector/general.c index ae8b2d75ef..cd00e382e6 100644 --- a/gtk/inspector/general.c +++ b/gtk/inspector/general.c @@ -15,6 +15,9 @@ * License along with this library. If not, see . */ +#include "config.h" +#include + #include "general.h" #include "gtkprivate.h" @@ -157,6 +160,14 @@ init_touch (GtkInspectorGeneral *gen) gtk_switch_set_active (GTK_SWITCH (gen->priv->touchscreen_switch), (gtk_get_debug_flags () & GTK_DEBUG_TOUCHSCREEN) != 0); g_signal_connect (gen->priv->touchscreen_switch, "notify::active", G_CALLBACK (update_touchscreen), gen); + + if (g_getenv ("GTK_TEST_TOUCHSCREEN") != 0) + { + /* hardcoded, nothing we can do */ + gtk_switch_set_active (GTK_SWITCH (gen->priv->touchscreen_switch), TRUE); + gtk_widget_set_sensitive (gen->priv->touchscreen_switch, FALSE); + gtk_widget_set_tooltip_text (gen->priv->touchscreen_switch, _("Setting is hardcoded by GTK_TEST_TOUCHSCREEN")); + } } static void diff --git a/gtk/inspector/visual.c b/gtk/inspector/visual.c index 435198aeac..4970119e2e 100644 --- a/gtk/inspector/visual.c +++ b/gtk/inspector/visual.c @@ -15,6 +15,8 @@ * License along with this library. If not, see . */ +#include "config.h" +#include #include "visual.h" #include "gtkprivate.h" @@ -211,6 +213,13 @@ init_theme (GtkInspectorVisual *vis) g_hash_table_destroy (t); gtk_combo_box_set_active (GTK_COMBO_BOX (vis->priv->theme_combo), pos); + + if (g_getenv ("GTK_THEME") != NULL) + { + /* theme is hardcoded, nothing we can do */ + gtk_widget_set_sensitive (vis->priv->theme_combo, FALSE); + gtk_widget_set_tooltip_text (vis->priv->theme_combo , _("Theme is hardcoded by GTK_THEME")); + } } static void @@ -230,6 +239,13 @@ init_dark (GtkInspectorVisual *vis) g_object_bind_property (vis->priv->dark_switch, "active", gtk_settings_get_default (), "gtk-application-prefer-dark-theme", G_BINDING_BIDIRECTIONAL); + + if (g_getenv ("GTK_THEME") != NULL) + { + /* theme is hardcoded, nothing we can do */ + gtk_widget_set_sensitive (vis->priv->dark_switch, FALSE); + gtk_widget_set_tooltip_text (vis->priv->dark_switch, _("Theme is hardcoded by GTK_THEME")); + } } static void -- 2.30.2